home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-01-30 | 2.0 KB | 64 lines | [TEXT/KAHL] |
- Ok, I am *tyring* to install a Gestalt selector. I want to
- install the 'SAVR' selector (or replace it if it exists)
- to trick Superclock into thinking a screen saver is active
- so it will disappear for a while. I have already traded
- e-mail with the author and he has told me what values to
- return, etc. So I was following example 3-5 in IM6 pg 3-43.
- All works fine until the DisposHandle call at the end,
- then I get dumped into MacsBug. If I comment it out
- my code works the way I want to. Superclock does turn
- off. I can even turn iut back on with another selector
- installation, again *without* calling DisposHandle.
- IM6 says the slector will stick around until a restart.
- So I am confused why the example calls DisposHandle
- and then it crashes for me. sniff sniff
-
- As specified in IM-6 ad the Think C manual, my callback
- routines are compiled as locked and system heap code
- resources, and like I said above they do seem to work.
-
- So here is some of the code...
-
- ProcPtr *oldGestaltFunction;
-
- /* DisableSuperclock will set the Gestalt selector 'savr' */
- /* to indicate that a screen saver, such as afterdark, */
- /* is enabled already, thus superclock will */
- /* not attempt to draw on the playing surface. */
- void DisableSuperClock()
- {
- OSErr myNewErr, myReplaceErr;
- int gstFuncRsrcID = 128;
- Handle gstFuncHandle;
- int SAVRTrouble = 130;
-
- gstFuncHandle = GetResource('GDEF', gstFuncRsrcID);
- if(gstFuncHandle == 0)
- Alert(SAVRTrouble,0);
- else
- {
- DetachResource(gstFuncHandle);
- myNewErr = NewGestalt('SAVR',*gstFuncHandle);
- if(myNewErr != noErr)
- {
- myReplaceErr = ReplaceGestalt('SAVR', *gstFuncHandle,
- oldGestaltFunction);
- if(myReplaceErr != noErr)
- Alert(SAVRTrouble,0);
- }
- }
- DisposHandle(gstFuncHandle);
- }
-
- main()
- {
- DisableSuperClock();
-
- I dont know if I have missed anything obvious, stupid, or
- what, but I have been banging my head on it for a few days
- so I dont think I will catch the trick by myself at this
- point.
-
- Thanks for any help,
- Mike
-